package android.os.mock.memory;

import android.app.ActivityManager;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * @hide
 * Information you can retrieve about the available memory through
 * {@link com.android.server.mock.memory.MockMemoryImpl#getMemoryInfo}.
 */
public class MockMemoryInfo implements Parcelable {
    /**
     * The available memory on the system.  This number should not
     * be considered absolute: due to the nature of the kernel, a significant
     * portion of this memory is actually in use and needed for the overall
     * system to run well.
     */
    public long availMem;

    /**
     * The total memory accessible by the kernel.  This is basically the
     * RAM size of the device, not including below-kernel fixed allocations
     * like DMA buffers, RAM for the baseband CPU, etc.
     */
    public long totalMem;

    /**
     * The threshold of {@link #availMem} at which we consider memory to be
     * low and start killing background services and other non-extraneous
     * processes.
     */
    public long threshold;

    /**
     * Set to true if the system considers itself to currently be in a low
     * memory situation.
     */
    public boolean lowMemory;

    /**
     *
     */
    public long total;

    /**
     *
     */
    public String heapGrowthLimit;

    /**
     *
     */
    public String heapSize;

    /**
     * The memory info get from the kernel(proc/memoryinfo)
     */
    public String memInfo;

    public MockMemoryInfo() {
    }

    public int describeContents() {
        return 0;
    }

    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(availMem);
        dest.writeLong(totalMem);
        dest.writeLong(threshold);
        dest.writeInt(lowMemory ? 1 : 0);
        dest.writeLong(total);
        dest.writeString(heapGrowthLimit);
        dest.writeString(heapSize);
        dest.writeString(memInfo);
    }

    public void readFromParcel(Parcel source) {
        availMem = source.readLong();
        totalMem = source.readLong();
        threshold = source.readLong();
        lowMemory = source.readInt() != 0;
        total = source.readLong();
        heapGrowthLimit = source.readString();
        heapSize = source.readString();
        memInfo = source.readString();
    }

    public static final @android.annotation.NonNull Creator<MockMemoryInfo> CREATOR
            = new Creator<MockMemoryInfo>() {
        public MockMemoryInfo createFromParcel(Parcel source) {
            return new MockMemoryInfo(source);
        }
        public MockMemoryInfo[] newArray(int size) {
            return new MockMemoryInfo[size];
        }
    };

    private MockMemoryInfo(Parcel source) {
        readFromParcel(source);
    }
}
